package cn.tedu.oa_system.controller;

import cn.tedu.oa_system.base.json_result.ResultDataDto;
import cn.tedu.oa_system.base.json_result.ResultDto;
import cn.tedu.oa_system.pojo.Dept;
import cn.tedu.oa_system.pojo.in.DeptIn;
import cn.tedu.oa_system.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author MW
 * @Description Dept控制器
 * @CreateDate 2022/12/25
 */
@Slf4j
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @GetMapping("/list")
    private ResultDataDto<Dept> list(){
        return deptService.list();
    }

    @PostMapping("/addnewdept")
    private ResultDto<Void> addDept(@RequestBody DeptIn deptIn){
        return deptService.addNewDept(deptIn);
    }

    @PostMapping("/updatedept")
    private ResultDto<Void> updateDept(@RequestBody DeptIn deptIn){
        return deptService.upDateDept(deptIn);
    }

    @PostMapping("/deletedept")
    private ResultDto<Void> deleteDept(@RequestBody Long deptId){
        return deptService.deleteDept(deptId);
    }
}
